import copy
from collections import defaultdict

n, m = map(int, input().split())
grid = defaultdict(list)
for _ in range(m):
    s, t, v = map(int, input().split())
    grid[s].append((t, v))
src, dst, k = map(int, input().split())

inf = float('inf')
minist = [inf] * (n + 1)
minist[src] = 0
for _ in range(k + 1):
    minist_prev = copy.copy(minist)
    for u in grid.keys():
        for v, w in grid[u]:
            minist[v] = min(minist[v], minist_prev[u] + w)
if minist[dst] == inf:
    print("unreachable")
else:
    print(minist[dst])
